<?php
/**
 * Created by PhpStorm.
 * User: papa
 * Date: 18/5/10
 * Time: 11:48
 */

namespace app\api\controller\v2;


use app\api\lib\exception\MissException;
use app\api\lib\exception\SuccessMessage;
use app\api\service\TokenService;
use think\Controller;

class BaseController extends Controller
{

    //token认证机制，检测当前登录用户
    protected function checkLogin()
    {
        TokenService::checkLogin();
    }

    //公共返回查询结果方法
    protected function doBack($data)
    {
        if($data){
            throw new SuccessMessage([
                'data' => $data,
            ]);
        }else{
            throw new MissException([
                'msg'=>'请求的信息不存在'
            ]);
        }
    }
}